/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GEOFENCE_MSDP_CLIENT_IMPL_H
#define GEOFENCE_MSDP_CLIENT_IMPL_H

#include <string>
#include <memory>
#include <vector>
#include <thread>
#include <map>
#include <errors.h>
#include <refbase.h>
#include "rdb_store.h"
#include "rdb_helper.h"
#include "rdb_open_callback.h"
#include "rdb_store_config.h"
#include "values_bucket.h"
#include "result_set.h"
#include "geofence_data_utils.h"
#include "geofence_rdb.h"
#include "geofence_data_utils.h"
#include "geofence_delayed_sp_singleton.h"
#include "igeofence_impl_interface.h"

namespace OHOS {
namespace Msdp {
class GeofenceImplClient {
public:
    using CallbackLocationManager = std::function<int32_t(GeofenceDataUtils::LocationData&)>;
    using CallbackCloudManager = std::function<int32_t(GeofenceDataUtils::CloudData&)>;

    ErrCode InitMsdpImpl();
    ErrCode RegisterLocationImpl(CallbackLocationManager callback);
    ErrCode RegisterCloudImpl(const GeofenceDataUtils::PoiOptions& poiOptions, CallbackCloudManager callback);
    int32_t MsdpLocationCallback(GeofenceDataUtils::LocationData& locationData);
    int32_t MsdpCloudCallback(GeofenceDataUtils::CloudData& fenceData);
    ErrCode EnableMsdp();
    ErrCode DisableMsdp();
    ErrCode RegisterLocationMsdp();
    ErrCode RegisterCloudMsdp(const GeofenceDataUtils::PoiOptions& poiOptions);
    ErrCode UnregisterLocationMsdp(void) const;
    ErrCode UnregisterCloudMsdp(void) const;
    GeofenceDataUtils::CloudData GetCloudCacheData(const GeofenceDataUtils::PoiOptions& poiOptions);
    void SetTrack(std::string timeString, int32_t screenState, std::string cell);
    void GetGeofenceTimestamp();
    void GetLongtitude();
    void GetLatitude();
private:
    ErrCode ImplLocationCallback    (GeofenceDataUtils::LocationData& locationData);
    ErrCode ImplCloudCallback    (GeofenceDataUtils::CloudData& fenceData);
    CallbackLocationManager callbacksLocationMgr_;
    CallbackCloudManager callbacksCloudMgr_;
    std::unique_ptr<IgeofenceImplInterface> msdpInterface_;
};
}
}
#endif // GEOFENCE_MSDP_CLIENT_IMPL_H

